package com.muyuan.web.controller.report;


import com.muyuan.report.domain.vo.ChangeStatisticsVO;
import com.muyuan.report.domain.vo.VulnerabilityMapVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.muyuan.common.core.domain.AjaxResult;
import com.muyuan.report.service.IReportService;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }

    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        //将当前日期格式化为字符串形式来进行传输
        return AjaxResult.success(reportService.getTodayInfo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())));
    }

    /**
     * 首页--获取待办数据
     *
     * @return
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(
                reportService.getTodoInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 龙虎榜商机转化
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(String beginCreateTime, String endCreateTime) {
        List<ChangeStatisticsVO> list = reportService.businessChangeStatistics(beginCreateTime, endCreateTime);
        return AjaxResult.success(list);
    }

    /**
     * 龙虎榜线索转化
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistics(
            @RequestParam("beginCreateTime") String beginCreateTime,
            @RequestParam("endCreateTime") String endCreateTime) {
        List<ChangeStatisticsVO> list = reportService.salesStatistic(beginCreateTime, endCreateTime);
        return AjaxResult.success(list);
    }


}